package gervosou;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.DropMode;
import java.awt.Color;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.GregorianCalendar;

public class VueNouvelleSociete extends Vue {
	
	private JLabel lblNomDeSocit;
	private JLabel lblAdresse;
	private JLabel lblTlphone;
	private JLabel lblEmail;
	
	private JPanel panel;
	
	private JTextField textFieldNom_soc;
	private JTextField textFieldAdresse_soc;
	private JTextField textFieldTel_soc;
	private JTextField textFieldEmail_soc;
	
	private JButton btnEnregistrer;
	private JButton btnAnnuler;
	
	public VueNouvelleSociete(Controleur c) {
		super(c);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 418, 243);
		panel = new JPanel();
		getContentPane().add(panel, BorderLayout.CENTER);
		panel.setLayout(null);
		
		lblNomDeSocit = new JLabel("Nom de société :");
		lblNomDeSocit.setBounds(72, 34, 114, 27);
		panel.add(lblNomDeSocit);
		
		textFieldNom_soc = new JTextField();
		textFieldNom_soc.setBounds(239, 35, 114, 19);
		panel.add(textFieldNom_soc);
		textFieldNom_soc.setColumns(10);
		
		lblAdresse = new JLabel("Adresse :");
		lblAdresse.setBounds(116, 68, 61, 15);
		panel.add(lblAdresse);
		
		lblTlphone = new JLabel("Téléphone :");
		lblTlphone.setBounds(103, 95, 83, 15);
		panel.add(lblTlphone);
		
		lblEmail = new JLabel("Email :");
		lblEmail.setBounds(134, 122, 52, 15);
		panel.add(lblEmail);
		
		textFieldAdresse_soc = new JTextField();
		textFieldAdresse_soc.setBounds(239, 66, 114, 19);
		panel.add(textFieldAdresse_soc);
		textFieldAdresse_soc.setColumns(10);
		
		textFieldTel_soc = new JTextField();
		textFieldTel_soc.setBounds(239, 93, 114, 19);
		panel.add(textFieldTel_soc);
		textFieldTel_soc.setColumns(10);
		
		textFieldEmail_soc = new JTextField();
		textFieldEmail_soc.setBounds(239, 120, 114, 19);
		panel.add(textFieldEmail_soc);
		textFieldEmail_soc.setColumns(10);
		
		btnEnregistrer = new JButton("Enregistrer");
		btnEnregistrer.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent v){
				String n = textFieldNom_soc.getText();
				String a = textFieldAdresse_soc.getText();
				String t = textFieldTel_soc.getText();
				String e = textFieldEmail_soc.getText();
				getControleur().nouvSociete(n, a, t, e);
			}
		});
		btnEnregistrer.setBounds(72, 174, 107, 25);
		panel.add(btnEnregistrer);
		
		btnAnnuler = new JButton("Annuler");
		btnAnnuler.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					getControleur().fermerVue(VueNouvelleSociete.this);}
		});
		btnAnnuler.setBounds(246, 174, 107, 25);
		panel.add(btnAnnuler);
		
		
	}

}
